/***************************************************************************
 *   Copyright (C) 2010 by Oleg Goncharov  *
 *   $EMAIL$                           *                          
 *                                                                         *
 *   This file is part of ChessVision.                                     *
 *                                                                         *
 *   ChessVision is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include <cmath>
#include "geomtypes.h"

using namespace std;

std::ostream& operator<<(std::ostream& out, const cv::Point3f& p) {
	return out << "(" << p.x << ", " << p.y << ", " << p.z << ")";
}

std::ostream& operator<<(std::ostream& out, const cv::Point2f& p) {
	return out << "(" << p.x << ", " << p.y << ")";	
}

bool Line2f::Intersect(const Line2f& line, cv::Point2f& point) const {
	if (teta == line.teta) return false;
	float s1 = sin(teta), c1 = cos(teta);
	float s2 = sin(line.teta), c2 = cos(line.teta);
	float det = c1*s2 - c2*s1;
	point.x = (r*s2 - line.r*s1) / det;
	point.y = (line.r*c1 - r*c2) / det;
	return true;
}
